//skill prices, now allowed to evolve over time
***********ACS Data***********
use "$temp/acs_master", clear //open

local kw = 1

//restrictions and regressoin variables
keep if uhrswork>=36 & uhrswork<=60 //restrict sample based on labor force attachment
gen black = (race == 2) //black dummy
gen male = (sex == 1) //sex dummy
gen hispanic = (hispan!=0) //hispanic

//kw sample
keep if year>=2008 & year<=2013
keep if age==18 | age == 19 | age == 20 //kw sample
keep if educ == 6 //HS grads only
keep statefip year black male hispanic educ wage_hourly perwt bpl age hours

//wrap up
compress
save "$temp/ACS_skill_price_sample", replace

***********Prep Census Data***********
use "$temp/census_master", clear

//sample restrictions
keep if uhrswork>=36 & uhrswork<=60 //restrict sample based on labor force attachment
keep if wkswork1>=50 //for ACS comparability

//regression variables
gen black = (race == 2) //black dummy
gen male = (sex == 1) //sex dummy
gen hispanic = (hispan!=0) //hispanic

//kw sample
keep if age==18 | age == 19 | age == 20 //kw sample
keep if educ == 6 //HS grads only
//keep statefip year black male hispanic educ wage_hourly perwt bpl age hours

//wrap up
append using "$temp/ACS_skill_price_sample" //add on ACS sample
compress
save "$temp/skill_price_dynamics_sample", replace

****MAIN REGRESSIONS***
use "$temp/skill_price_dynamics_sample", clear
gen period = 1
replace period = 2 if year>=2008
drop if period==2
ren statefip stfips

//log wage variable
gen l_wage = log(wage_hourly)

//regression based on strategy
qreg l_wage black male hispanic i.age ib19.stfips [fweight=perwt]

//convert to data
levelsof stfips, clean local (fips)
clear
set obs 50
gen statefips = .
gen skill_price_p1 = .
gen skill_price_p2 = .
local counter = 0

//loop over fips and fill in skill prices
foreach fip in `fips'{
	local counter `++counter'
	
	replace statefips = `fip' in `counter'
	replace skill_price_p1 = _b[`fip'.stfips#1.period] in `counter'
	replace skill_price_p2 = _b[`fip'.stfips#2.period] in `counter'
}	

//exponentiate and save
replace skill_price_p1 = exp(skill_price_p1)
replace skill_price_p2 = exp(skill_price_p2)
save "$temp/skill_prices_kw", replace

//from here, make scatterplots

